//
//  HLUserInfoModel.m
//  YueYue
//
//  Created by hulu001 on 2023/5/17.
//

#import "HLUserInfoModel.h"

@implementation HLUserInfoModel

- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property
{
    if ([property.name isEqualToString:@"userOpuses"]){
        return [HLOpusModel mj_objectArrayWithKeyValuesArray:oldValue];
    } else if ([property.name isEqualToString:@"jlUserPriceConfig"]){
        return [HLUserPriceModel mj_objectWithKeyValues:oldValue];
    } else if ([property.name isEqualToString:@"tagVOS"]){
        return [HLHomeTagModel mj_objectArrayWithKeyValuesArray:oldValue];
    }
    
    return oldValue;
}

- (NSString *)shortName
{
    NSString *name = _nickName;
    if (name.length > 6){
        name = [NSString stringWithFormat:@"%@...", [name substringWithRange:NSMakeRange(0, 6)]];
    }
    return name;
}

- (NSString *)ageString
{
    if (_age.length > 0){
        return _age;
    }
    return @"0";
}

- (NSString *)occupationString
{
    if (_occupation.length > 0){
        return _occupation;
    }
    return @"未填写";
}

- (NSString *)sexName
{
    if ([_sex isEqualToString:@"1"]){
        return @"男";
    }
    return @"女";
}

- (NSString *)weightString
{
    if (_weight.length > 0){
        if ([_weight containsString:@"kg"]){
            return _weight;
        }
        return [NSString stringWithFormat:@"%@kg", _weight];
    }
    return @"0kg";
}

- (NSString *)heightString
{
    if (_height.length > 0){
        if ([_height containsString:@"cm"]){
            return _height;
        }
        return [NSString stringWithFormat:@"%@cm",_height];
    }
    return @"0cm";
}

- (NSString *)selfSign
{
    if (_selfSign.length > 0){
        return _selfSign;
    }
    
    return @"TA太懒了还没有补充个性签名~";
}

- (HLOpusModel *)videoWithUserOpuses
{
    for (HLOpusModel *opus in _userOpuses) {
        if ([opus.opusType isEqualToString:@"2"]){
            return opus;
        }
    }
    return nil;
}

- (NSArray<HLOpusModel *> *)imagesWithUserOpuses
{
    HLOpusModel *video = [self videoWithUserOpuses];
    NSMutableArray *images = [NSMutableArray arrayWithArray:self.userOpuses];
    [images removeObject:video];
    return [images copy];
}

- (void)resetLocal
{
    self.avatarImage = nil;
    self.userOpuseImages = nil;
    self.userOpuseUrlsChangeState = nil;
}

- (void)tipAction
{
    [HLUIHelper showAlertInfoWithTitle:@"图片上传规范" content:@"1.相册需上传本人真实照片\n2.不得上传涉证、涉恐、涉暴、涉警和带有管制器具等图片\n3.不得上传露点露毛，凸点，性暗示，低俗，大尺度图片和淫秽漫画图片等；\n4.不得上传带有任何其他联系方式的图片，包括微信、QQ、微博、手机号等\n5.不得盗用其他人的照片\n6.上述违规内容将会被封禁处理"];
}

@end
